package games.singleplayer;

import java.util.Random;

import model.Coordinate;
import model.entity.Entity2D;
import model.mobs.Mob2D;
import model.spawner.Spawner2D;

public class SinglePlayerSpawner extends Spawner2D{

	//Variabili di supporto.
	
	private int minX;
	private int spawnRange;
	private int spawnY;
	private Random r;
	
	
	public SinglePlayerSpawner(int minX, int maxX, int spawnY) {
		this.minX = minX;
		this.spawnRange = maxX-minX;
		this.spawnY = spawnY;
		this.r = new Random();
	}

	@Override
	public void createEntity() {
		int ID = getBufferIndex();
		Coordinate coo = new Coordinate( minX + r.nextInt(spawnRange), spawnY, 0);
		Entity2D entity = new Mob2D(ID, coo, 0);
		insertEntity( entity );
		entity.start();
	}
	
}
